package com.fxb.springtheory.entity;

import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;

/**
 * 测试用户是否注入成功
 * @author fangjiaxiaobai [公众号：方家小白]
 * @date 2020-07-10 11:41
 * @since 1.0.0
 */
public class PersonDemo {

    public static void main(String[] args) {
        XmlBeanFactory xmlBeanFactory = new XmlBeanFactory(new ClassPathResource("application.xml"));
        Person person1 = xmlBeanFactory.getBean("person1", Person.class);
        System.out.println(
                String.format("person1的用户名为:[%s],密码为:[%s]", person1.getUsername(), person1.getPassword()));
        Person person2 = xmlBeanFactory.getBean("person2", Person.class);
        System.out.println(
                String.format("person2的用户名为:[%s],密码为:[%s]", person2.getUsername(), person2.getPassword()));
    }

}
